//
//  MusicTools.m
//  LZMusicPlayer
//
//  Created by wulanzhou on 2016/11/23.
//  Copyright © 2016年 wulanzhou. All rights reserved.
//

#import "MusicTools.h"

@interface MusicTools (){
    NSInteger _currentIndex;
}

@end

@implementation MusicTools

+ (MusicTools *)shareInstance{
    static dispatch_once_t pred = 0;
    __strong static MusicTools *_sharedObject = nil;
    dispatch_once(&pred, ^{
        _sharedObject = [[self alloc] init]; // or some other init method
    });
    return _sharedObject;
}


- (instancetype)init{

    if (self = [super init]) {
        _currentIndex = 0;
        self.musicPlayType = MusicPlayQueueType;
    }
    return self;
}

- (BMAMusic *)currentMusic{

    if (self.musicList&&[self.musicList count]>0&&_currentIndex < [self.musicList count]) {
        return self.musicList[_currentIndex];
    }
    return nil;
}

- (void)nextMusic{
    _currentIndex ++;
    if (_currentIndex >= [self.musicList count]) {
        _currentIndex = [self.musicList count] -1;
    }
}

- (void)prevMusic{
    _currentIndex --;
    if (_currentIndex < 0) {
        _currentIndex = 0;
    }
}

@end
